$(function () {
    /*选择器变量抽取*/
    var gift_dg = $("#gift_datagrid");
    gift_dg.datagrid({
        width: 780,
        height: 500,
        fitColumns:true,
        url: "/giftbill/query.do",
        sortName: "inputTime",
        sortOrder: "desc",
        columns:[[
            {field:'memberName',title:'会员名字',width:100},
            {field:'giftName',title:'礼品名称',width:100},
            {field:'number',title:'兑换数量',width:100,},
            {field:'points',title:'兑换一个所需积分',width:100},
            {field:'totalPoints',title:'兑换需要的积分',width:100},
            {field:'inputId',title:'操作人ID',width:100},
            {field:'inputName',title:'操作人名字',width:100},
            {field:'inputTime',title:'兑换时间',width:100,sortable: true,order:"desc"},
        ]],
        toolbar:"#gift_tb",
        singleSelect:true,
        pagination:true,
        rownumbers: true,
    })

    //给所有的A标签,绑定点击事件
    $("a[data-cmd]").click(function () {
        var method = $(this).data("cmd");
        //调用方法
        objMethod[method]();
    })

    //把方法绑定到对象上
    var objMethod = {
        //刷新
        reload:function () {
            //刷新页面
            gift_dg.datagrid("reload");
        },
        //高级查询
        queryForKey:function () {
            //获取到表格参数值
            var keyword = $("input[name=keyword]").val();
            var beginDate = $("input[name=beginDate]").val();
            var endDate = $("input[name=endDate]").val();
            //重新加载到表格数据中,使用load方法
            gift_dg.datagrid("load",{
                "keyword":keyword,"beginDate":beginDate,"endDate":endDate})
        },

    }


})